<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		*{
			margin: 0;
			padding: 0;
			list-style: none;
		}

		#b{
			width: 100px;
		}

		#b li{
			width: 20px;
			height: 24px;
			text-align: center;
			line-height: 24px;
			float: left;
		}

		#b .l{
			border-bottom: 1px solid red;
		}
		
		div{
			width: 200px;
			height: 100px;
			margin-top: 10px;
			display: none;
			border: 1px solid lime;
		}

		#b::after{
			content: "";
			display: block;
			clear: both;
		}
	
		.d1{
			display: block;
		}
        
	</style>
</head>
<body>
	<ul id="b">
		<li class="l">1</li>
		<li>2</li>
		<li>3</li>
		<li>4</li>
	</ul>

	<section id="d">
		<div class="d1">111</div>
		<div>222</div>
		<div>333</div>
		<div>444</div>
	</section>
	
	<script>
		var oli=b.children;
		var od=d.children;

		for(var i=0;i<oli.length;i++)
		{
			oli[i].index=i;
			oli[i].onclick=function(){
				for(var j=0;j<oli.length;j++){
					oli[j].className='';
					od[j].className='';
				}
				var index=this.index;
				this.className='l';
				od[index].className='d1';

			}
		}
	</script>

</body>
</html>